<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 多态  不同类(构造函数)的对象 在调用同一个方法 会显示不同的结果

    // JS弱类型语言 是无态的 天生就支持多态
    class Cat {
        constructor(name, color) {
            this.name = name;
            this.color = color;
        }
        call() {
            console.log("喵喵");
        }
    }

    class Dog {
        constructor(name, color) {
            this.name = name;
            this.color = color;
        }
        call() {
            console.log("汪汪");
        }
    }

    class Pig {
        constructor(name, color) {
            this.name = name;
            this.color = color;
        }
        call() {
            console.log("哼哼");
        }
    }

    var cat = new Cat("小美", "white");
    var dog = new Dog("旺财", "yellow");
    var pig = new Pig("佩奇", "pink");

    function AnimalCall(animal) {
        animal.call();
    }
    AnimalCall(cat);
    AnimalCall(dog);
    AnimalCall(pig);


</script>

</html>